﻿using Quartz;
using Quartz.Impl;
using Quartz.Impl.Triggers;
using StackExchange.Profiling;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using zichan.Models;

namespace zichan
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.Initialize();
            
                
            
            //ModelBinders.Binders.Add(typeof(string), new StringTrimModelBinder());//为全局重写一个模型绑定器，自动去除空格
            //AreaRegistration.RegisterAllAreas();
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());
           // Database.SetInitializer(new DropCreateDatabaseIfModelChanges<zichan.DAL.ZichanDBContext>());
           
        }
        protected void Application_BeginRequest()
        {
            if (Request.IsLocal)
            {
                MiniProfiler.Start();
            }
        }

        protected void Application_EndRequest()
        {
            MiniProfiler.Stop();
        }
        protected void Session_End(object sender, EventArgs e)
        {
            string sid = Session.SessionID;
            if (HttpRuntime.Cache[sid + "zcqxmenu"] != null)
                HttpRuntime.Cache.Remove(sid + "zcqxmenu");
        }

       
    }
}
